// 新增 student 表 数据
const studentDB = require("../schemas/student");

// 创建随机函数
const randomNum = (min, max) => {
  return Math.floor(Math.random() * (max - min + 1)) + min;
};
// 随机电话
const randomPhone = () => {
  let str = "1";
  for (let i = 0; i < 10; i++) {
    str += randomNum(0, 9);
  }
  return str;
};


//随机取值
const arr = [
  {
    // 类别
    kindName: "后端",
    // 课程名
    courseName: "Python基础核心语法",
    // 班期名
    className: [
      "55期开发基础班",
      "53期开发基础班",
      "52期开发基础班",
      "51期开发基础班",
    ],
  },
  {
    kindName: "后端",
    courseName: "Python全栈开发",
    className: ["6-7全栈开发班", "4-28全栈开发班", "3-17全栈开发班"],
  },
  {
    kindName: "前端",
    courseName: "web前端基础班",
    className: ["三十七期javacript", "三十九期javacript"],
  },
  {
    kindName: "前端",
    courseName: "web前端全栈进阶班",
    className: [
      "web-前端进阶框架-朱雀",
      "web-前端进阶框架-cherry ",
      "web-前端进阶框架-丸子",
    ],
  },
];

for (let i = 0; i < 500; i++) {
  const num = randomNum(0, arr.length - 1);
  const randomPhoneNumber = randomPhone();
  const item = arr[num]; //取出对象

  const classNum = randomNum(0, item.className.length - 1)

  studentDB.create({
    phoneNumber: randomPhoneNumber,
    kindName: item.kindName,
    courseName: item.courseName,
    className: item.className[classNum],
    updatePeople: "铁锤",
    updateTime: Date.now(), // 获取当前时间戳
    info: {
      phoneNumber: randomPhoneNumber,
    },
  });
}
